<template>
  <Table :data="list" :cols="cols">
    <template v-slot:level="{ row:{level}}">
        <el-tag :type='colors[level]'>{{levels[level]}}级</el-tag>
         </template>
  </Table>
</template>

<script>
import { getRights } from "@/api/role";
/** 
 * 等级
*/
const levels=["一","二","三"];
/** 
 * 颜色
*/
const colors=["","success","warning"];
/**
 * 列
 */
const cols = [
  {
    title: "#",
    type: "index",
  },
  {
    title: "权限名称",
    name: "authName",
  },
  {
    title: "路径",
    name: "path",
  },
  {
    title: "权限等级",
    slot: "level",
  },
];
export default {
  name: "RightsList",
  data() {
    return {
        /** 
         * 等级
        */
        levels,
        /** 
         * 颜色
        */
        colors,
        /** 
         * 列
        */
        cols,
      /**
       * 数据列表
       */
      list: [],
    };
  },
  methods: {
    /**
     * 获取权限列表
     */
    async getRightsList() {
      try {
        this.list = await getRights();
      } catch (error) {}
    },
  },
  created() {
    this.getRightsList();
  },
  mounted() {},
  components: {},
  computed: {},
  watch: {},
};
</script>

<style lang='less' scoped>
</style>